package review.chapter00;

import java.util.Scanner;

/**
 * Enjoy programming!!!
 * Time: 2021/12/21 -  20:59
 */
public class NestedBranch {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("请输入季节：");
        String season = in.nextLine();

        System.out.print("要买几张：");
        int n = in.nextInt();

        System.out.print("请分别输入年龄：");
        int[] type = new int[n];
        for (int i = 0; i < n; i++) {
            type[i] = in.nextInt();
        }
        int sum = 0;

        if (season.equals("旺季")) {
            for (int i = 0; i < n; i++) {
                if (type[i] <= 60 && type[i] >= 18) {
                    sum += 60;
                } else if (type[i] < 18) {
                    sum += 30;
                } else if (type[i] > 60) {
                    sum += 20;
                } else {
                    System.out.println("对不起，您输入的年龄出错了，请重新输入,或转人工售票处购票");
                    System.out.println("是否重新输入？(Y/N)");
                    String w = in.nextLine();
                    if (w.equals("Y")) {

                        int age = in.nextInt();
                        type[i] = age;
                        i--;
                    }
                }
            }
        } else if (season.equals("淡季")) {
            for (int i = 0; i < n; i++) {
                if (type[i] <= 60 && type[i] >= 18) {
                    sum += 40;
                } else if (type[i] < 18 && type[i] > 60) {
                    sum += 30;
                } else {
                    System.out.println("对不起，您输入的年龄出错了，请重新输入,或转人工售票处购票");
                    System.out.println("是否重新输入？(Y/N)");
                    String w = in.nextLine();
                    if (w.equals("Y")) {
System.out.print("请重新输入：");
                        int age = in.nextInt();
                        type[i] = age;
                        i--;
                    }
                }
            }
        }
        System.out.printf("应付金额：%d\n",sum);
    }
}
